/*
 * StatusCodes.c
 *
 *  Created on: 17/set/2013
 *      Author: Ialenti Andrea, Marangon Fabio
 */

#include "../headers/StatusCodes.h"

char* getStatusMessage(Status s) {

	switch(s) {
		case SUCCESS:			return "Function executed successfully.";

		case ERR_MEM_ALLOC:		return "Memory allocation and/or initialization error!";

		case ERR_READ_FILE:		return "Error reading a file.";
		case ERR_WRITE_FILE:	return "Error writing to a file.";

		case ERR_PLOT:			return "Plot function error.";

		case ERR_SIMPL_PROB:	return "An error occurred while simplifying the original problem.";
		case ERR_RM_EDGES:		return "Error removing useless graph edges.";

		case ERR_IMPORT_GRAPH:	return "An error occurred while importing a graph.";

		case ERR_CPX:			return "Generic CPLEX error.";

		case ERR_CREATE_PROB:	return "Error creating the CPLEX problem representation.";

		case ERR_TESTER:		return "Module 'Tester.c' error.";

		case ERR_MAIN:			return "Module 'main.c' error.";

		case ERR_TIME:			return "Time limit reached.";

		case ERR_BB_GENERIC:	return "Generic branch and bound error.";

		case ERR_GENERIC:		return "Generic function error.";

		default:				return "Unknown error!";
	}
	return "Unknown error!";
}

int getStatusCode(Status s) {

	switch(s) {
		case SUCCESS:			return 0;

		case ERR_MEM_ALLOC:		return -10;

		case ERR_READ_FILE:		return -1;
		case ERR_WRITE_FILE:	return -2;

		case ERR_PLOT:			return -20;

		case ERR_SIMPL_PROB:	return -31;
		case ERR_RM_EDGES:		return -32;

		case ERR_IMPORT_GRAPH:	return -41;

		case ERR_CPX:			return -51;

		case ERR_CREATE_PROB:	return -61;

		case ERR_TESTER:		return -70;

		case ERR_MAIN:			return -80;

		case ERR_TIME:			return -90;

		case ERR_BB_GENERIC:	return -110;

		case ERR_GENERIC:		return -200;

		default:				return -666;
	}
	return -666;
}
